package cn.zhangxin.pethome.utils;

import io.swagger.models.auth.In;
import lombok.Data;
/**
 * 这个工具类用于，封装controller返回的对象
 * */
@Data
public class AjaxResult {
    //返回消息
    private String msg;
    //返回状态
    private Boolean success;
    //返回的对象
    private Object data;
    //返回的总条数
    private Long total;
    //连带父id
    private Long pid;

    /* 私有化构造方法 */
    private AjaxResult() {}

    /* 私有化构造方法 */
    private AjaxResult(String msg, Boolean success) {
        this.msg = msg;
        this.success = success;
    }
    public static AjaxResult success(){
       return new AjaxResult("成功",true);
    }
    public static AjaxResult error(){
        return new AjaxResult("失败",false);
    }
    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;
    }

    public AjaxResult setData(Object data) {
        this.data = data;
        return this;
    }

    public AjaxResult setTotal(Long total) {
        this.total = total;
        return this;
    }
    public AjaxResult setPid(Long pid) {
        this.pid = pid;
        return this;
    }
}
